<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition template="/WEB-INF/templates/templateMenu.xhtml">

	<ui:define name="body">
		<a4j:form>
			<rich:toolBar>
				<h:outputText styleClass="texto_negrito" value="Cadastro e Manutenção de Fórmulas" />
				<rich:toolBarGroup location="right">
					<a4j:commandLink action="#{formulaBean.gravar}" reRender="tblFormulas,panelCadFormulas"	rendered="#{empty rendered_btgravar ? true : rendered_btgravar}">
						<h:graphicImage style="border: none;" url="/imagens/disk.png" />
						<h:outputText value="Gravar" />
					</a4j:commandLink>
				</rich:toolBarGroup>
			</rich:toolBar>
			
			<h:panelGrid columns="3" id="panelCadFormulas">
				<h:outputLabel value="Nome da Fórmula" />
				<h:inputText value="#{formulaBean.formula.nome}" required="true" id="inForNome" />
				<rich:message for="inForNome"/>
				
				<h:outputLabel value="Tipo" />
				<h:inputText value="#{formulaBean.formula.tipo}" required="true" id="inForTipo" />
				<rich:message for="inForTipo" />
				
				<h:outputLabel value="Descrição da Fórmula"/>
				<h:inputText value="#{formulaBean.formula.descricao}" required="true" id="inForDesc" />
				<rich:message for="inForDesc"/>								
			</h:panelGrid>
			<rich:separator height="8" width="100%" lineType="beveled"></rich:separator>
			<h:panelGrid width="100%" id="panelListaFormula">
				<rich:dataTable var="formula" value="#{formulaBean.listaFormulas}" id="tblFormulas" binding="#{formulaBean.tblFormulas}" width="100%" rowClasses="tb_cor2,tb_cor1" rows="10">
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Fórmula" />
						</f:facet>
						<h:outputText value="#{formula.nome}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Tipo" />
						</f:facet>
						<h:outputText value="#{formula.tipo}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Descrição" />
						</f:facet>
						<h:outputText value="#{formula.descricao}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Ações" />
						</f:facet>
						<h:panelGrid columns="2" cellpadding="5">
							<a4j:commandLink ajaxSingle="true" action="#{formulaBean.delete}" reRender="tblFormulas">
								<h:graphicImage border="0" value="/imagens/delete.png" />
								<h:outputText value="Excluir" />
							</a4j:commandLink>

							<a4j:commandLink ajaxSingle="true"	action="#{formulaBean.edicaoFormula}">
								<h:graphicImage border="0" value="/imagens/edit.png" />
								<h:outputText value="Alterar" />
							</a4j:commandLink>
						</h:panelGrid>
					</rich:column>				
				</rich:dataTable>			
			</h:panelGrid>
			<rich:datascroller for="tblFormulas"/>
		</a4j:form>
	</ui:define>

</ui:composition>

</html>